# coding:utf-8
r''' 主入口
 * @ 作  者: 阿拉丁矿工 黄传鸿 <hchhyzc@foxmail.com>
 * @ 描  述: 主入口
'''
# ==========================================================|引入包
from tornado.routing import Router
import tornado.web
import tornado.ioloop
import tornado.options
import tornado.httpserver
from urls.urls import urls
from tornado.options import options, define
from tornado.web import RequestHandler
import os

define("port", default=2114, type=int, help="爱你一生")
# static_path = os.path.join(os.paht.dirname(__file__), "statics")	#这里增加设置了静态路径
current_path = os.path.dirname(__file__)
# ==========================================================|公共函数
# 应用程序


class Application(tornado.web.Application):
    '''应用程序'''

    def __init__(self, *args, **kwargs):
        super(Application, self).__init__(*args, **kwargs)

# 主函数


def main():
    '''主函数'''
    tornado.options.parse_command_line()
    app = tornado.web.Application(
        urls,
        static_path=os.path.join(current_path, "statics"),
        template_path=os.path.join(current_path, "templates"),
        debug=False
    )
    http_server = tornado.httpserver.HTTPServer(app)
    http_server.listen(options.port)
    tornado.ioloop.IOLoop.current().start()


# 入口函数
if __name__ == "__main__":
    '''入口函数'''
    main()
